﻿using CsvHelper.Configuration.Attributes;
using DM_TOOLS.Tools.DBC.HEX;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DM_TOOLS.Tools.DBC.DBCCSV
{
    public class DBCCSVMappingClass
    {
        [Name("HardwareTS")]
        public long HardwareTS { get; set; }

        [Name("TimeStamp")]
        public string? TimeStamp { get; set; }   // 可以改成 DateTime，如果格式固定

        [Name("Device")]
        public uint Device { get; set; }

        [Name("Channel")]
        public uint Channel { get; set; }

        [Name("Direction")]
        public string? Direction { get; set; }

        [Name("FrameType")]
        public string? FrameType { get; set; }

        [Name("FrameFormat")]
        public string? FrameFormat { get; set; }

        [Name("CanID")]
        [TypeConverter(typeof(HexToDecimalConverter))]   // 自动转成十进制 int
        public uint CanID { get; set; }

        [Name("DLC")]
        public int DLC { get; set; }

        [Name("FrameData")]
        [TypeConverter(typeof(FrameDataConverter))]     // 自动转成 byte[]，byte本质上就是一个8位无符号整数，范围为0 ~ 255，2个16进制取值范围也是0 ~ 255，所以可以转换为1个byte
        public byte[] FrameData { get; set; } = Array.Empty<byte>();

        [Name("BRS")]
        public string? BRS { get; set; }

        [Name("Error")]
        public int Error { get; set; }
    }
}
